package com.ruoyi.wechat.api;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.wechat.domain.CAppointment;
import com.ruoyi.wechat.service.ICAppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wechat/appointment")
public class WxAppointmentController extends BaseController {

    @Autowired
    private ICAppointmentService cAppointmentService;
    /**
     * 查询营地预约列表
     */

     //查询营地预约列表
    @GetMapping("/list")
    public TableDataInfo list(CAppointment cAppointment)
    {
        startPage();
        List<CAppointment> list = cAppointmentService.selectCAppointmentList(cAppointment);
        return getDataTable(list);
    }


    /**
     * 获取营地预约详细信息
     */
    //获取营地预约详细信息
    @GetMapping(value = "/{appointId}")
    public AjaxResult getInfo(@PathVariable("appointId") String appointId)
    {
        return success(cAppointmentService.selectCAppointmentByAppointId(appointId));
    }

    /**
     * 新增营地预约
     */
    //新增营地预约
    @PostMapping
    public AjaxResult add(@RequestBody CAppointment cAppointment)
    {
        return toAjax(cAppointmentService.insertCAppointment(cAppointment));
    }

    /**
     * 修改营地预约
     */
    //修改营地预约
    @PutMapping
    public AjaxResult edit(@RequestBody CAppointment cAppointment)
    {
        return toAjax(cAppointmentService.updateCAppointment(cAppointment));
    }


}